import * as user from './foo'
console.log((user as any).name)
let isDone: boolean= false
let str: string ='asd'
let dec: number=6
let sss:any=''
let lianhe:string|number=1
lianhe='2323'
//对象的类型
interface Person {
    readonly name:string;
    age:number;
    sex:string;
    iseat?:boolean;
}
let jim:Person={
    name:'jim',
    age:10,
    sex:'m',
    
}
jim.sex='hahah'
let arr:number[]=[1,2,3]
let brr: Array<number>=[1,2,3]
const foo:number= 1;
(window as any).foo=1
function fn(p:string):void{
    alert(222)
}
let sum=(x:number,y:number)=>{
    return x+y
}
// 断言 as
// 泛型 <T>
function setage<T>(asd:T):T{
    return asd
}
// declare .d.ts 声明文件 声明全局变量
namespace vs {
    export const str="sssss";
    export function say(a:string):string {
        return a
    }
    export const value="ssssss"
}
console.log(vs.value)
// 元组 提前定义好内容的数组
let toms:[string,number]=['s',11]
toms.push('sdfgh')

enum Days {Sun,Mon,Tue,Wed,Thu,Fri,Sat}
Days['Sun']===0
enum Color {Red,Green,Bue}
enum Dires {Up='w',Down="s",Left="a",Right="d"}
interface Alarm {
    name:string;
    alert():void;

}
interface Light{
    lightOn():void;
    lightOff():void;
}
class Door{

}
class SecurityDoor extends Door implements Alarm,Light{
    name="hello world"
    alert(): void {
        console.log('安全门')
    }
    lightOn(): void {
        
    }
    lightOff(): void {
        
    }
}
// ts中接口可以extends继承 接口，类
// 类要implements实现接口
// T U
function say<T,U>(a:T,B:U):T{
    console.log(B)
    return a
}
// interface 解释对象 type 基本类型也可以 interface 可以定义多次，自动合并但是不能有冲突使用extends 扩展
// type 类型别名 相当于起了一个别名，通过扩展运算符去扩展
type Name=string
type obj={
    name:string;
    age:number;
}
type Cname = Name & obj
interface obj1{
    name:string;
    sayHi():void;
    eat(a:string):string;
}
interface obj1{
    age:number;
    sex:string;
}
function http(){
    return new Promise((resolve,reject)=>{
        const data={name:'Jerry',age:10}
        resolve(data)
    })
}
http().then().catch()


